package com.zeropoint.demo.pojo;


import lombok.ToString;

/**
 * 社会资源指标标准化
 */
@ToString
public class SocialResourceStandardized {

    //数据汇总
    //家庭成员担任村组干部
    public int villageCadres;
    //发生困难时得到他人帮助
    public int othersHelp;
    //家庭成员参与社会组织
    public int socialOrganizations;
    //是否享受政策贴息贷款
    public int isPolicyLoan;
    //是否向亲戚朋友处借款
    public int isBorrowMoney;
    //社会交往次数
    public int socialTimes;

    //数据整理
    //政策贴息贷款数额
    public double policyLoanAmount;
    //亲戚朋友处借款数额
    public double borrowMoneyAmount;

    //计算结果
    //担任村组干部赋值
    public double villageCadreAssignment;
    //发生困难时得到帮助赋值
    public double helpAssignment;
    //参与社会组织赋值
    public double socialAssignment;
    //政策贴息贷款赋值
    public double policyLoanAssignment;
    //向亲戚朋友处借款赋值
    public double borrowMoneyAssignment;
    //社会交往次数赋值
    public double socialTimesAssignment;

    //contactNumber为表5的社会交往次数V
    public SocialResourceStandardized(int contactNumber, FormTwo formTwo){
        villageCadres = formTwo.village_cadres_number + formTwo.other_village_cadres_number;

        if("很多".equals(formTwo.borrow_money_number)){
            othersHelp = 1;
        }else if("较多".equals(formTwo.borrow_money_number)){
            othersHelp = 2;
        }else if("一般".equals(formTwo.borrow_money_number)){
            othersHelp = 3;
        }else if("较少".equals(formTwo.borrow_money_number)){
            othersHelp = 4;
        }else if("很少".equals(formTwo.borrow_money_number)){
            othersHelp = 5;
        }

        socialOrganizations = formTwo.social_welface_organization_number;

        if(formTwo.policy_borrow_number > 0){
            isPolicyLoan = 1;
        }else {
            isPolicyLoan = 0;
        }

        if(formTwo.friend_borrow_number > 0){
            isBorrowMoney = 1;
        }else {
            isBorrowMoney = 0;
        }

        socialTimes = contactNumber;

        policyLoanAmount = formTwo.policy_borrow_money*10000;
        borrowMoneyAmount = formTwo.friend_borrow_money*10000;

        if(villageCadres == 0){
            villageCadreAssignment = 0;
        }else if(villageCadres == 1){
            villageCadreAssignment = 0.8;
        }else {
            villageCadreAssignment = 1;
        }

        helpAssignment = (double) othersHelp/5;

        if(socialOrganizations == 0){
            socialAssignment = 0;
        }else if(socialOrganizations == 1){
            socialAssignment = 0.8;
        }else {
            socialAssignment = 1;
        }

        if(policyLoanAmount == 0){
            policyLoanAssignment = 0;
        }else if(policyLoanAmount < 20000){
            policyLoanAssignment = policyLoanAmount/20000;
        }else {
            policyLoanAssignment = 1;
        }

        if(borrowMoneyAmount == 0){
            borrowMoneyAssignment = 0;
        }else if(borrowMoneyAmount < 20000){
            borrowMoneyAssignment = borrowMoneyAmount/20000;
        }else {
            borrowMoneyAssignment = 1;
        }

        if(socialTimes == 0){
            socialTimesAssignment = 0;
        }else if(socialTimes == 1){
            socialTimesAssignment = 0.33;
        }else if(socialTimes == 2){
            socialTimesAssignment = 0.66;
        }else {
            socialTimesAssignment = 1;
        }
    }

    public static void main(String[] args) {
        FormTwo formTwo = new FormTwo();
        formTwo.mon_communication_fee = 70;
        formTwo.mon_electricity_fee = 100;
        formTwo.borrow_money_number = "很少";
        formTwo.village_cadres_number = 0;
        formTwo.other_village_cadres_number = 0;
        formTwo.commercial_insurance_number = 0;
        formTwo.commercial_insurance_outcome = 0;
        formTwo.social_welface_organization_number = 0;
        formTwo.policy_borrow_number = 1;
        formTwo.policy_borrow_money = 50000;
        formTwo.friend_borrow_number = 1;
        formTwo.friend_borrow_money = 10000;
        System.out.println(new SocialResourceStandardized(0, formTwo));
    }
}
